package com.liuyucheng.generic.wildcard;

public class Box<E> {
    private E first;

    public E getFirst() {
        return first;
    }

    public void setFirst(E first) {
        this.first = first;
    }

    /**
     * 类型通配符
     * @param box 对象
     * Box<? extends Number> 类型通配符的上限
     */
    public static void showBox(Box<? extends Number> box){
        Number first = box.getFirst();
        System.out.println("first = " + first);
    }

    public static void main(String[] args) {
        Box<Number> box = new Box<>();
        box.setFirst(100);
        showBox(box);

        Box<Integer> integerBox = new Box<>();
        integerBox.setFirst(100);
        showBox(integerBox);
    }
}
